#!/usr/bin/python
# -*- coding: utf-8 -*-
# vim: set fileencoding=utf-8

import sys, os, getopt, re
import codecs
import sqlite3
from SCTC import *


def main(argv):
    file_db = 'dpedia.db.sqlite'
    con = sqlite3.connect(file_db)
    con.row_factory = sqlite3.Row
    cur = con.cursor()

    cur.execute('select id, data from pedia')
    dataArray = cur.fetchall()
    for row in dataArray:
        #t = (sc_to_tc(row[1]), row[0])
        t = (row[1].replace('file_res/img_doc/', ''), row[0])
        cur.execute("update pedia set data=? where id=?", t)

    con.commit()
    cur.close()


if __name__ == '__main__':
    main(sys.argv[1:])

